<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8"/>
        <title>入库页面</title>
        <meta content="webkit" name="renderer"/>
        <link href="../../css/font.css" rel="stylesheet"/>
        <link href="../../css/xadmin.css" rel="stylesheet"/>
        <script charset="utf-8" src="../../lib/layui/layui.js"></script>
        <script src="../../js/xadmin.js" type="text/javascript"></script>
        <script src="../../js/vue2.7min.js"></script>
        <script src="../../js/axios.min.js"></script>
    </head>
    <body>
        <div class="x-nav">
            <a
                    class="layui-btn layui-btn-small"
                    onclick="location.reload()"
                    style="line-height: 1.6em; margin-top: 3px; float: right"
                    title="刷新"
            >
                <i class="layui-icon layui-icon-refresh" style="line-height: 30px"></i
                ></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card" id="app">
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>操作者id</th>
                                    <th>商品id</th>
                                    <th>仓库id</th>
                                    <th>入库数量</th>
                                </tr>
                                </thead>
                                <tbody>

                                <!--模板开始-->
                                <tr v-for="(item , index) in records">
                                    <td>{{index+1}}</td>
                                    <td v-text="item.masterId"></td>
                                    <td v-text="item.goodsId"></td>
                                    <td v-text="item.warehouseId"></td>
                                    <td v-text="item.number"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="layui-card-body">
                            <div class="page">
                                <div>
                                    <a @click="getAll('-')"
                                       class="prev">&lt;&lt;</a>


                                    <a @click="getAll('-')" class="num" v-if="current>1" v-text="current-1"></a>
                                    <span class="current" v-text="current"></span>
                                    <a @click="getAll('+')" class="num" v-if="current<pages"
                                       v-text="current+1"></a>


                                    <a @click="getAll('+')" class="num" v-if="current+1 < pages"
                                       v-text="pages"></a>


                                    <a @click="getAll('max')" class="next">&gt;&gt;</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script type="text/javascript">
            var vm = new Vue({
                el: "#app",
                data: {
                    //管理员信息
                    id: null,
                    name: null,
                    level: null,
                    phone: null,
                    realName: null,
                    sex: null,
                    status: null,
                    createTime: null,
                    updateTime: null,
                    createUser: null,
                    updateUser: null,
                    //分页属性
                    current: 1,
                    records: null,
                    total: null,
                    size: null,
                    pages: null,
                    //供应商信息
                    supplierId: null,
                    supplierMaster: null,
                    supplierName: null,
                    supplierPhone: null,
                    supplierAddress: null,
                    supplierMessage: null,
                    supplierEmail: null,
                    supplierStatus: null,
                    supplierCreateTime: null,
                    supplierUpdateTime: null,
                    supplierCreateUser: null,
                    supplierUpdateUser: null,
                    //商品信息
                    goodsId: null,
                    goodsName: null,
                    goodsSupplierId: null,
                    goodsPrice: null,
                    goodsMessage: null,
                    goodsAddress: null,
                    //名下供应商信息
                    managerSuppliers: null,
                    managerSuppliersOnlySuppliersId: null


                },
                methods: {
                    //获取初始数据，
                    getAll(num2) {
                        var jsonD = null;
                        if (num2 === "first") {
                            //默认查询第一页
                            jsonD = {num1: 1}
                        } else {
                            //不是第一次
                            var aimCurrent = vm.current;
                            //判断参数操作符好
                            if (num2 === '-') {
                                if (vm.current === 1) {
                                    aimCurrent = 1;
                                } else {
                                    aimCurrent = aimCurrent - 1;
                                }
                            } else if (num2 === '+') {
                                if (vm.current < vm.pages) {
                                    aimCurrent = aimCurrent + 1;
                                } else {
                                    aimCurrent = vm.pages;
                                }
                            } else if (num2 === 'max') {
                                aimCurrent = vm.pages;
                            }
                            jsonD = {num1: aimCurrent}
                        }
                        axios.post("../../../purchase/getLog", jsonD)
                            .then(function (response) {
                                //数据保存到vue全局
                                if (response.data.code === 1) {
                                    vm.current = response.data.data.current;
                                    vm.records = response.data.data.records;
                                    vm.total = response.data.data.total;
                                    vm.size = response.data.data.size;
                                    vm.pages = response.data.data.pages;
                                }

                            })
                    }

                },
                mounted: function () {
                    //获取分页信息
                    this.getAll("first");


                }
            });
        </script>
    </body>

</html>
